import React, { useEffect } from "react"
import ReactDOM from "react-dom/client"
import App from "./App"
import { ConfigProvider, App as AntApp, message } from "antd"
import { HashRouter } from "react-router-dom"
import zhCN from "antd/lib/locale/zh_CN"
import { initBaseModules } from "@/config/echartsConfig"
import theme from "./config/theme"
import { initMessageService } from "@/utils/messageService.js"
// import "default-passive-events"
import "@/assets/styles/reset.css"
import "virtual:uno.css"

// 按需挂载echarts
initBaseModules()
const RootComponent = () => {
  const [messageApi, contextHolder] = message.useMessage()
  // 初始化 messageService
  useEffect(() => {
    initMessageService(messageApi)
  }, [messageApi])
  return (
    <HashRouter>
      <ConfigProvider
        locale={zhCN}
        theme={{
          ...theme
        }}
      >
        <AntApp>
          {contextHolder}
          <App />
        </AntApp>
      </ConfigProvider>
    </HashRouter>
  )
}

ReactDOM.createRoot(document.getElementById("root")).render(<RootComponent />)
